/*
  File: PermissionEntity.cs
  Author: rcrxy
  CreateTime: 2025/06/26 18:36

  Description: 权限表
*/

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 权限配置
/// </summary>
[Table("permission")]
[Index(nameof(Code), IsUnique = true)]
public class PermissionEntity: BaseEntity {

   /// <summary>
   /// 显示名称
   /// </summary>
   [MaxLength(50)]
   public string? Name { get; set; }

   /// <summary>
   /// 唯一标识 格式: controller/action:method
   /// </summary>
   [MaxLength(150)]
   public required string Code { get; set; }

   /// <summary>
   /// 描述
   /// </summary>
   [MaxLength(255)]
   public string? Description { get; set; }

   /// <summary>
   /// 是否启用
   /// </summary>
   public bool Enable { get; set; } = true;

   [InverseProperty(nameof(RolePermissionMapEntity.Permission))]
   public ICollection<RolePermissionMapEntity>? RolePermissionMaps { get; set; }
}
